{% load i18n %}
<div class="table-responsive">
    <table class="table table-calendar">
        <thead>
        <tr>
            <th>{{ weeks.1.0.date|date:"D" }}</th>
            <th>{{ weeks.1.1.date|date:"D" }}</th>
            <th>{{ weeks.1.2.date|date:"D" }}</th>
            <th>{{ weeks.1.3.date|date:"D" }}</th>
            <th>{{ weeks.1.4.date|date:"D" }}</th>
            <th>{{ weeks.1.5.date|date:"D" }}</th>
            <th>{{ weeks.1.6.date|date:"D" }}</th>
        </tr>
        </thead>
        <tbody>
        {% for week in weeks %}
            <tr>
                {% for day in week %}
                    {% if day %}
                        <td class="day {% if day.events %}has-events{% else %}no-events{% endif %}"
                            data-date="{{ day.date|date:"SHORT_DATE_FORMAT" }}">
                            <h3>{{ day.day }}</h3>
                            <div class="events">
                                {% for event in day.events %}
                                    <a class="event {% if event.continued %}continued{% else %} {% spaceless %}
    {% if event.event.presale_is_running and show_avail %}
        {% if event.event.best_availability_state == 100 %}
            available
        {% elif event.event.settings.waiting_list_enabled and event.event.best_availability_state >= 0 %}
            waitinglist
        {% elif event.event.best_availability_state == 20 %}
            reserved
        {% elif event.event.best_availability_state < 20 %}
            soldout
        {% endif %}
    {% elif event.event.presale_is_running %}
        running
    {% elif event.event.presale_has_ended %}
        over
    {% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
        soon
    {% else %}
        soon
    {% endif %}
{% endspaceless %}{% endif %}"
                                       href="{{ event.url }}">
                                        {% if show_names|default_if_none:True %}
                                            <span class="event-name">
                                                {{ event.event.name }}
                                            </span>
                                        {% endif %}
                                        {% if not event.continued %}
                                            {% if event.time %}
                                                <span class="event-time" data-time="{{ event.event.date_from.isoformat }}" data-timezone="{{ event.timezone }}" data-time-short>
                                                    <span class="fa fa-clock-o" aria-hidden="true"></span>
                                                    {% if not show_names|default_if_none:True %}
                                                        <strong>
                                                    {% endif %}
                                                    {{ event.time|date:"TIME_FORMAT" }}
                                                    {% if event.event.settings.show_date_to and event.time_end %}
                                                        – {{ event.time_end|date:"TIME_FORMAT" }}
                                                    {% endif %}
                                                    {% if not show_names|default_if_none:True %}
                                                        </strong>
                                                    {% endif %}
                                                    {% if multiple_timezones %}
                                                        {{ event.timezone }}
                                                    {% endif %}
                                                </span>
                                            {% endif %}
                                            <span class="event-status">
                                                {% if event.event.presale_is_running and show_avail %}
                                                    {% if event.event.best_availability_state == 100 %}
                                                        <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Book now" %}
                                                    {% elif event.event.settings.waiting_list_enabled and event.event.best_availability_state >= 0 %}
                                                        <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Waiting list" %}
                                                    {% elif event.event.best_availability_state == 20 %}
                                                        <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Reserved" %}
                                                    {% elif event.event.best_availability_state < 20 %}
                                                        {% if event.event.has_paid_item %}
                                                            <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Sold out" %}
                                                        {% else %}
                                                            <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Fully booked" %}
                                                        {% endif %}
                                                    {% endif %}
                                                {% elif event.event.presale_is_running %}
                                                    <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Book now" %}
                                                {% elif event.event.presale_has_ended %}
                                                    <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Sale over" %}
                                                {% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
                                                    <span class="fa fa-ticket" aria-hidden="true"></span>
                                                    {% blocktrans with start_date=event.event.presale_start|date:"SHORT_DATE_FORMAT" %}
                                                        from {{ start_date }}
                                                    {% endblocktrans %}
                                                {% else %}
                                                    <span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Soon" %}
                                                {% endif %}
                                            </span>
                                        {% endif %}
                                    </a>
                                {% endfor %}
                            </div>
                        </td>
                    {% else %}
                        <td class="no-day"></td>
                    {% endif %}
                {% endfor %}
            </tr>
        {% endfor %}
        <tr class="selected-day">
            <td colspan="7"></td>
        </tr>
        </tbody>
    </table>
</div>
